﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.MountAndBlade.WeaponData
// Assembly: TaleWorlds.MountAndBlade, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: D5209D1B-76B5-47CA-B957-255CD4B2CE6B
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.dll

using System.Runtime.InteropServices;
using TaleWorlds.Core;
using TaleWorlds.DotNet;
using TaleWorlds.Engine;
using TaleWorlds.Library;
using TaleWorlds.ObjectSystem;

#nullable disable
namespace TaleWorlds.MountAndBlade
{
  [EngineStruct("Weapon_data", "TaleWorlds.MountAndBlade.AutoGenerated.WeaponDataAsNative", false)]
  public struct WeaponData
  {
    public MetaMesh WeaponMesh;
    public MetaMesh HolsterMesh;
    public MetaMesh HolsterMeshWithWeapon;
    public MetaMesh FlyingMesh;
    [CustomEngineStructMemberData("prefab_name")]
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
    public string Prefab;
    [CustomEngineStructMemberData("body")]
    public PhysicsShape Shape;
    [CustomEngineStructMemberData("collision_body")]
    public PhysicsShape CollisionShape;
    public Material TableauMaterial;
    public MatrixFrame WeaponFrame;
    public int PhysicsMaterialIndex;
    public int WeaponKind;
    public StackArray.StackArray4Int ItemHolsterIndices;
    public int Difficulty;
    public float BaseWeight;
    public float Inertia;
    public short ReloadPhase;
    public bool HasFlagAnimation;
    public Vec3 AmmoOffset;
    public MatrixFrame StickingFrame;
    public float ScaleFactor;
    public float CenterOfMass;
    [CustomEngineStructMemberData("center_of_mass_3d")]
    public Vec3 CenterOfMass3D;
    public Vec3 HolsterPositionShift;
    public int FlyingSoundCode;
    public int PassbySoundCode;
    [CustomEngineStructMemberData("flying_missile_trail_particle_name")]
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
    public string TrailParticleName;
    public Vec3 CenterOfMassShift;
    public short DataValue;
    public int CurrentUsageIndex;
    public float AirFrictionConstant;
    public bool HasLowerHolsterPriority;
    public float GlossMultiplier;
    public static WeaponData InvalidWeaponData = new WeaponData()
    {
      WeaponKind = -1
    };

    public bool IsValid() => this.WeaponKind >= 0;

    public ItemObject GetItemObject()
    {
      return (this.WeaponKind >= 0 ? MBObjectManager.Instance.GetObject(new MBGUID((uint) this.WeaponKind)) : (MBObjectBase) null) as ItemObject;
    }

    public void DeinitializeManagedPointers()
    {
      if ((NativeObject) this.WeaponMesh != (NativeObject) null)
        this.WeaponMesh.ManualInvalidate();
      if ((NativeObject) this.HolsterMesh != (NativeObject) null)
        this.HolsterMesh.ManualInvalidate();
      if ((NativeObject) this.HolsterMeshWithWeapon != (NativeObject) null)
        this.HolsterMeshWithWeapon.ManualInvalidate();
      if (!((NativeObject) this.FlyingMesh != (NativeObject) null))
        return;
      this.FlyingMesh.ManualInvalidate();
    }
  }
}
